package com.midea.ai.air.ui.device;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;

import com.midea.ai.air.R;
import com.midea.ai.air.common.ActionBarFragement;
import com.midea.ai.air.common.BaseFragment;
import com.midea.ai.air.common.ConsVal;
import com.midea.ai.air.common.Constant;
import com.midea.ai.air.utils.L;
import com.midea.ai.air.utils.Machine;

/**
 * Created by guojun3 on 2015-12-8.
 */
public class DeviceFragmemt extends BaseFragment {

    FrameLayout mBarLayout;
    RelativeLayout mLayout;
    ActionBarFragement mBarFragment;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mLayout = (RelativeLayout) inflater.inflate(R.layout.fragment_device, container, false);
        initView(mLayout);
        return mLayout;
    }

    private void initView(View v) {
        mBarLayout = (FrameLayout) v.findViewById(R.id.bar_parent);
        ViewGroup.LayoutParams LP = mBarLayout.getLayoutParams();
        LP.height = Constant.getTopMargin() + getResources().getDimensionPixelSize(R.dimen.height_44dp);
        mBarLayout.setLayoutParams(LP);

        mBarFragment = (ActionBarFragement) getChildFragmentManager().findFragmentById(R.id.bar_fragment);
        mBarFragment.getTitle().setText("家电");

        mBarFragment.getIvAdd().setImageResource(R.drawable.air_appliances_add);
        mBarFragment.getIvAdd().setVisibility(View.VISIBLE);

        mBarFragment.setCurrentPage(ConsVal.ACTIVITY_TAG_DEVICE);
    }

    @Override
    public void onResume() {
        super.onResume();
        if (getManager().getCurrentIndex() == 1) {
            Machine.initSystemBar(getActivity(), true);
            L.i("JUNE", "DeviceFragmemt onResume");
        }
    }
}
